package cn.school.thoughtworks.section3;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class PracticeC {
    Map<String,Integer> createUpdatedCollection(List<String> collectionA, Map<String,List<String>> object) {
        //实现练习要求，并改写该行代码。


        Map<String,Integer> collection3=new HashMap<String,Integer>();
        for(int i=0;i<collectionA.size();i++){
            Integer sum=collection3.get(collectionA.get(i));
            collection3.put(collectionA.get(i), sum==null?1:sum+1);
        }
        for (String s:collection3.keySet()){
            for(String x:object.get("value")){
                if (s.equals(x)&&collection3.get(s)>=3){
                    Integer i = collection3.get(s);
                    collection3.put(s,i-i/3);
                }
                collection3.put(s,collection3.get(s));

            }

        }
        return collection3;
    }
}
